#include <stdio.h>
#include "compacta.h"

struct s {
	int s;
	char e;
	char y5;
};

struct h {
	short s1;
	char u;
	int i6;
	char v;
};

struct ex {
  short s1;
  int i1;
  char c1;
  int i2;
  short s2;
  char c2;
};

/*
	Regras do array campos:
 
	char 1
	short int 2
	int 3
	fim 0
*/

void printEx( FILE* arq ) {
	char c;

	while (fread( &c, sizeof(char), 1, arq ) == 1)  {
		printf("%d\n", c);
	}
}

int main() {
	FILE* arq = fopen("arq.bin", "wb");
	
	struct s es[2];
	es[0].s=1;
	es[0].e='c';
	es[0].y5='4';
	es[1].s=54;
	es[1].e=5;
	es[1].y5=2;

	char vecS[] = {3, 1, 1, 0};
	char vecH[] = {2, 1, 3, 1, 0};
	char vecEx[] = {2, 3, 1, 3, 2, 1, 0};

	gravacompactado( &es, 2, vecS, 0, arq);
/*	gravacompactado( NULL, 1, vecH, 1, arq);
	gravacompactado( NULL, 1, vecEx, 1, arq);
*/
	/* Falta o corpo da main */

	fclose(arq);

	arq = fopen("arq.bin", "rb");

	printEx(arq);

	fclose(arq);

	return 0;
}
